@import "../../themes/ionic.globals.ios";

// iOS Checkbox
// --------------------------------------------------

/// @prop - Background color of the checkbox when off
$checkbox-ios-background-color-off:       $list-ios-background-color !default;

/// @prop - Background color of the checkbox when on
$checkbox-ios-background-color-on:        color($colors-ios, primary) !default;

/// @prop - Size of the checkbox icon
$checkbox-ios-icon-size:                  21px !default;

/// @prop - Border color of the checkbox icon when off
$checkbox-ios-icon-border-color-off:      $list-ios-border-color !default;

/// @prop - Border color of the checkbox icon when on
$checkbox-ios-icon-border-color-on:       $checkbox-ios-background-color-on !default;

/// @prop - Border width of the checkbox icon
$checkbox-ios-icon-border-width:          1px !default;

/// @prop - Border style of the checkbox icon
$checkbox-ios-icon-border-style:          solid !default;

/// @prop - Border radius of the checkbox icon
$checkbox-ios-icon-border-radius:         50% !default;

/// @prop - Width of the checkbox icon checkmark
$checkbox-ios-icon-checkmark-width:       1px !default;

/// @prop - Style of the checkbox icon checkmark
$checkbox-ios-icon-checkmark-style:       solid !default;

/// @prop - Color of the checkbox icon checkmark
$checkbox-ios-icon-checkmark-color:       color-contrast($colors-ios, $checkbox-ios-background-color-on) !default;

/// @prop - Opacity of the disabled checkbox
$checkbox-ios-disabled-opacity:           .3 !default;

/// @prop - Margin of the left checkbox item
$checkbox-ios-item-left-margin:           $item-ios-padding-media-top $item-ios-padding-right $item-ios-padding-media-bottom 2px !default;

/// @prop - Margin of the right checkbox item
$checkbox-ios-item-right-margin:          10px 8px 9px 0 !default;


.checkbox-ios {
  position: relative;
  display: inline-block;
}


// iOS Checkbox Outer Circle: Unchecked
// -----------------------------------------

.checkbox-ios .checkbox-icon {
  position: relative;

  width: $checkbox-ios-icon-size;
  height: $checkbox-ios-icon-size;

  border-width: $checkbox-ios-icon-border-width;
  border-style: $checkbox-ios-icon-border-style;
  border-radius: $checkbox-ios-icon-border-radius;
  border-color: $checkbox-ios-icon-border-color-off;
  background-color: $checkbox-ios-background-color-off;
}


// iOS Checkbox Outer Circle: Checked
// -----------------------------------------

.checkbox-ios .checkbox-checked {
  border-color: $checkbox-ios-icon-border-color-on;
  background-color: $checkbox-ios-background-color-on;
}


// iOS Checkbox Inner Checkmark: Checked
// -----------------------------------------

.checkbox-ios .checkbox-checked .checkbox-inner {
  position: absolute;
  top: 4px;
  left: 7px;

  width: 4px;
  height: 9px;

  border-width: $checkbox-ios-icon-checkmark-width;
  border-top-width: 0;
  border-left-width: 0;
  border-style: $checkbox-ios-icon-checkmark-style;
  border-color: $checkbox-ios-icon-checkmark-color;
  transform: rotate(45deg);
}


// iOS Checkbox: Disabled
// -----------------------------------------

.checkbox-ios.checkbox-disabled,
.item-ios.item-checkbox-disabled ion-label {
  opacity: $checkbox-ios-disabled-opacity;

  pointer-events: none;
}


// iOS Checkbox Within An Item
// -----------------------------------------

.item.item-ios .checkbox-ios {
  position: static;
  display: block;

  margin: $checkbox-ios-item-left-margin;
}

.item.item-ios .checkbox-ios[item-right] {
  margin: $checkbox-ios-item-right-margin;
}


// iOS Checkbox Color Mixin
// --------------------------------------------------

@mixin checkbox-theme-ios($color-name, $color-base, $color-contrast) {

  .checkbox-ios-#{$color-name} .checkbox-checked {
    border-color: $color-base;
    background-color: $color-base;
  }

  .checkbox-ios-#{$color-name} .checkbox-checked .checkbox-inner {
    border-color: $color-contrast;
  }

}


// Generate iOS Checkbox Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
  @include checkbox-theme-ios($color-name, $color-base, $color-contrast);
}
